IF and IFZ
IF statements test the following expression for TRUE (non-zero), as does the synonym
statement IFT (if TRUE ). Quite often, however, it is more natural to test for
FALSE. IFZ (if zero) and IFF (if false) are equivalent and provided to test for zero
aka false. The following examples illustrate all forms of the IF statement.
FUNCTION IfDemo(x, y) lines=none
IF x THEN PRINT "x is TRUE,
(non-zero)"
IFT x THEN PRINT "x is TRUE, (non-zero)"
IFF x THEN PRINT "x is FALSE, (zero)"
IFZ x THEN PRINT "x is ZERO, (zero)"
IF x$ THEN PRINT "x$ is TRUE,
(non-empty-string)"
IFT x$ THEN PRINT "x$ is TRUE,
(non-empty-string)"
IFF x$ THEN PRINT "x$ is FALSE,
(empty-string)"
IFZ x$ THEN PRINT "x$ is ZERO, (empty-string)"
IF x[] THEN PRINT "x[] is TRUE,
(non-empty-array)"
IFT x[] THEN PRINT "x[] is TRUE, (non-empty-array)"
IFF x[] THEN PRINT "x[] is FALSE, (empty-array)"
IFZ x[] THEN PRINT "x[] is ZERO, (empty-array)"
IF f() THEN PRINT "f() returned TRUE,
(non-zero)"
IFT f() THEN PRINT "f() returned TRUE, (non-zero)"
IFF f() THEN PRINT "f() returned FALSE, (zero)"
IFZ f() THEN PRINT "f() returned ZERO, (zero)"
END FUNCTION